xenstored: add --event parameter for bootstrapping
authorDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 9 Feb 2012 18:33:35 +0000 (18:33 +0000)
committerDaniel De Graaf <dgdegra@tycho.nsa.gov>
Thu, 9 Feb 2012 18:33:35 +0000 (18:33 +0000)
When xenstored is run in a minios domain, it needs a bootstrap
connection to dom0 so that additional domain introduce messages can be
sent to it.

Signed-off-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
tools/xenstore/xenstored_core.c
tools/xenstore/xenstored_core.h
tools/xenstore/xenstored_domain.c
tools/xenstore/xenstored_minios.c

index a762db714f7f13b4eaaf17332ea6e15e319284eb..40e2fc0c8b4426b0babe045355e9a93bed0e0509 100644 (file)
@@ -1749,6 +1749,7 @@ static struct option options[] = {
        { "no-domain-init", 0, NULL, 'D' },
        { "entry-nb", 1, NULL, 'E' },
        { "pid-file", 1, NULL, 'F' },
+       { "event", 1, NULL, 'e' },
        { "help", 0, NULL, 'H' },
        { "no-fork", 0, NULL, 'N' },
        { "output-pid", 0, NULL, 'P' },
@@ -1763,6 +1764,7 @@ static struct option options[] = {
        { NULL, 0, NULL, 0 } };
 
 extern void dump_conn(struct connection *conn); 
+int dom0_event = 0;
 
 int main(int argc, char *argv[])
 {
@@ -1820,6 +1822,9 @@ int main(int argc, char *argv[])
                case 'W':
                        quota_nb_watch_per_domain = strtol(optarg, NULL, 10);
                        break;
+               case 'e':
+                       dom0_event = strtol(optarg, NULL, 10);
+                       break;
                }
        }
        if (optind != argc)
index f0749551be24901a7b7f914a4b380d870761c5f5..e1c2be7a48302b5550f8365d26c0ed1596ce1198 100644 (file)
@@ -168,6 +168,7 @@ void trace(const char *fmt, ...);
 void dtrace_io(const struct connection *conn, const struct buffered_data *data, int out);
 
 extern int event_fd;
+extern int dom0_event;
 
 /* Map the kernel's xenstore page. */
 void *xenbus_map(void);
@@ -190,6 +191,8 @@ void finish_daemonize(void);
 /* Open a pipe for signal handling */
 void init_pipe(int reopen_log_pipe[2]);
 
+xc_gnttab **xcg_handle;
+
 #endif /* _XENSTORED_CORE_H */
 
 /*
index 62069612b730d93a157868fef6df3e8a5b3bb054..558e5cbc594c9e7e50ea50f701d2859fa00df9d1 100644 (file)
@@ -35,7 +35,7 @@
 #include <xen/grant_table.h>
 
 static xc_interface **xc_handle;
-static xc_gnttab **xcg_handle;
+xc_gnttab **xcg_handle;
 static evtchn_port_t virq_port;
 
 xc_evtchn *xce_handle = NULL;
index c8700baa58b6b52217ce62468b3ec17f0abd0451..1c6f794d394e72562cd4d6792bc1d3e505a4be6b 100644 (file)
@@ -46,15 +46,17 @@ void xenbus_notify_running(void)
 
 evtchn_port_t xenbus_evtchn(void)
 {
-       return -1;
+       return dom0_event;
 }
 
 void *xenbus_map(void)
 {
-       return NULL;
+       return xc_gnttab_map_grant_ref(*xcg_handle, 0,
+                       GNTTAB_RESERVED_XENSTORE, PROT_READ|PROT_WRITE);
 }
 
 void unmap_xenbus(void *interface)
 {
+       xc_gnttab_munmap(*xcg_handle, interface, 1);
 }